﻿Imports System.Data
Imports System.Collections.ObjectModel

Public Class CSGeneralGL


    Public Function ObtieneFondosSaldos(ByVal IdCatSolicitud As Integer, ByVal IdClaveSolicitud As Integer, ByVal strFecha As String) As List(Of CTSaldoFondosPS)
        Dim lstFondos As New List(Of CTSaldoFondosPS)
        Dim lstFondosSaldos As New List(Of CTSaldoFondosPS)
        Try
            lstFondos = ObtieneFondos(IdCatSolicitud, IdClaveSolicitud)
            If (lstFondos.Count > 0)
                lstFondosSaldos = ObtieneSaldosFondos(lstFondos, strFecha)
            End If
                
            
            Return lstFondosSaldos

        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Private Function ObtieneFondos(ByVal IdCatSolicitud As Integer, ByVal IdClaveSolicitud As Integer) As List(Of CTSaldoFondosPS)
        Try
            Dim lstFondos As New List(Of CTSaldoFondosPS)
            Dim dtDatos      As DataTable = CFLServicioLocalSQLServerDB.ObtieneFondos(IdCatSolicitud, IdClaveSolicitud)
            Dim c            As CTSaldoFondosPS

            If dtDatos.Rows.Count > 0 Then
                For Each dt As DataRow In dtDatos.Rows
                    c = New CTSaldoFondosPS()
                    With c
                        .Fondo = Convert.ToString(dt(0))
                    End With
                    lstFondos.Add(c)
                    c = Nothing
                Next
            End If

            Return lstFondos
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Private Function ObtieneSaldosFondos(ByRef lstFondos As List(Of CTSaldoFondosPS), ByVal strFecha As String) As List(Of CTSaldoFondosPS)
        Try
            Dim lstFondosSaldos As New List(Of CTSaldoFondosPS)
            Dim dtDatos      As DataTable = CFLServiciosMacrosSyBaseDB.ObtieneSaldosFondos(lstFondos, strFecha)
            Dim c            As CTSaldoFondosPS

            If dtDatos.Rows.Count > 0 Then
                For Each dt As DataRow In dtDatos.Rows
                    c = New CTSaldoFondosPS()
                    With c
                        .Fondo = Convert.ToString(dt(0))
                        .Saldo = Convert.ToDouble(dt(1))
                    End With
                    lstFondosSaldos.Add(c)
                    c = Nothing
                Next
            End If

            Return lstFondosSaldos
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Public Sub GuardaPartidaSolicitud(ByVal IdCatSolicitud As Integer, ByVal IdClaveSolicitud As Integer, ByVal strFecha As String)
        Dim lstFondos As New List(Of CTSaldoFondosPS)
      
    End Sub

End Class
